#!/usr/bin/env python
# coding: utf-8

def consumer():
    r = ''
    while True:
        n = yield r
        if not n:
            return
        r = "200 ok"

def producer(c):
    c.send(None)
    for n in range(1,6):
        print("[producer]: product %d"%n)
        r = c.send(n)
        print("[producer]: return %s"%r)
    c.close()

'''
[producer]: product 1
[producer]: return 200 ok
[producer]: product 2
[producer]: return 200 ok
[producer]: product 3
[producer]: return 200 ok
[producer]: product 4
[producer]: return 200 ok
[producer]: product 5
[producer]: return 200 ok
'''
c = consumer()
producer(c)